using UnityEngine;
using System.Collections;

public class LabelObjectStatHandler : MonoBehaviour {

	public ObjectType type;
	public UILabel label;
	public UITexture texture;
	
	private bool shouldDisplay = true;
	
	void OnGUI(){
		
		switch(type){
		case ObjectType.Filter:
			label.text = LevelConstants.nbFilter +"/"+LevelConstants.maxFilter;
			if(LevelConstants.nbFilter == LevelConstants.maxFilter){
				label.text = "[FF0000]"+label.text;	
			}
			if(LevelConstants.maxFilter == 0){
				shouldDisplay = false;
			}else{
				shouldDisplay = true;
			}
			break;
		case ObjectType.Mirror:
			label.text = LevelConstants.nbMirror +"/"+LevelConstants.maxMirror;
			if(LevelConstants.nbMirror == LevelConstants.maxMirror){
				label.text = "[FF0000]"+label.text;	
			}
			if(LevelConstants.maxMirror == 0){
				shouldDisplay = false;
			}else{
				shouldDisplay = true;
			}
			break;
		case ObjectType.Mixer:
			label.text = LevelConstants.nbMixer +"/"+LevelConstants.maxMixer;
			if(LevelConstants.nbMixer == LevelConstants.maxMixer){
				label.text = "[FF0000]"+label.text;	
			}
			if(LevelConstants.maxMixer == 0){
				shouldDisplay = false;
			}else{
				shouldDisplay = true;
			}
			break;
		case ObjectType.Divider:
			label.text = LevelConstants.nbDivider +"/"+LevelConstants.maxDivider;
			if(LevelConstants.nbDivider == LevelConstants.maxDivider){
				label.text = "[FF0000]"+label.text;	
			}
			if(LevelConstants.maxDivider == 0){
				shouldDisplay = false;
			}else{
				shouldDisplay = true;
			}
			break;
		}
		
		if(shouldDisplay){
			NGUITools.SetActiveChildren(gameObject,true);
		}else{
			NGUITools.SetActiveChildren(gameObject,false);
		}
		
	}
	
}
